package com.weslide.weslideapp.parser;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.weslide.weslideapp.pojo.ao.AddScoreAO;

public class AddScoreParser {
	private AddScoreAO addScoreAO = new AddScoreAO();

	public void parser(String jsonString) throws JSONException {
		JSONArray jsonArray = new JSONArray(jsonString);
		JSONObject statusJsonObject = jsonArray.getJSONObject(0);
		addScoreAO.setStatus(statusJsonObject.getString("status"));
		if (addScoreAO.getStatus().equals("1")) {
			JSONObject dataJsonObject = jsonArray.getJSONObject(1);
			addScoreAO.setUserId(dataJsonObject.getString("user_id"));
			addScoreAO.setScore(dataJsonObject.getString("score"));
			addScoreAO.setTotalScore(dataJsonObject.getString("total_score"));
		}
	}

	public AddScoreAO getData() {
		return addScoreAO;
	}
}
